<?php
	include '../func/sql.php';
	session_start();
	if(isset($_POST['user']) && isset($_POST['pass'])){
		$user = $_POST['user'];
		$pass = $_POST['pass'];
		if(strlen($pass) < 5 || strlen($user) < 4){
			header("Location: index.php?error=0");
		}
		settype($user,"string");
		settype($pass,"string");
		
		$sql = sprintf("SELECT pass FROM users WHERE user = '%s';",$user);
		$res = sendQ($sql);
		$resA = mysql_fetch_array($res);
		
		print_r($resA);
		
		$sqlPass = $resA['pass'];
		echo $pass . ' = ' .$sqlPass;
		if($sqlPass == $pass){
			$_SESSION['loggedin'] = "BOBCAT";
			header("Location: index.php");
		}else{
			header("Location: index.php?error=0");
		}
		
	}else{
		header("Location: index.php?error=0");
	}
	
?>
